<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        ul{
            list-style: none;
        }
        li{
            background-color: blueviolet;
            margin: 10px 0px;
        }
    </style>
</head>
<body>

    <ul>
        <li>列表1</li>
        <li>列表2</li>
        <li>列表3</li>
    </ul>

    
    <script>
        var lis=document.querySelectorAll("li")
        for(var i=0;i<lis.length;i++)
        {
            (function(b){
                setTimeout(function(){
                    console.log('当前li==>',+b,'内容'+lis[b].innerText);
                },3000)
            })(i)
            // (function(i){
            //     lis[i].onclick=function()
            //     {
            //         alert(i)
            //     }
            // })(i)
        }
    </script>
    
</body>
</html>